package com.netmarch.dao;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.netmarch.entity.User;

public interface UserDao extends JpaRepository<User, Long> , JpaSpecificationExecutor<User>{
	
	List<User> findByName(String name);
	
	int countByName(String name);
	
	@SuppressWarnings("unchecked")
	User save(User user);
	
	@Modifying
	@Transactional
	@Query("update User set name=?1 where code = ?2")
	int updateUserByName(String name,String code);
	
	@Query("from User where name = ?1")
	List<User> getAllByName(String name);
	
}
